/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.compatibility.common.util;

import java.util.List;

/**
 * Represents a single test result.
 */
public interface ITestResult extends Comparable<ITestResult> {

    /**
     * @return The name of this test result.
     */
    String getName();

    /**
     * @return The full name of this test result, ie
     * &lt;package-name&gt;.&lt;class-name&gt;#&lt;method-name&gt;
     */
    String getFullName();

    /**
     * @return The {@link TestStatus} of this result.
     */
    TestStatus getResultStatus();

    /**
     * Sets the {@link TestStatus} of the result and updates the end time of the test.
     *
     * @param status The {@link TestStatus} of this result.
     */
    void setResultStatus(TestStatus status);

    /**
     * @return The failure message to display
     */
    String getMessage();

    /**
     * @param message The message to display which describes the failure
     */
    void setMessage(String message);

    /**
     * @return The stack trace generated by the failure
     */
    String getStackTrace();

    /**
     * @param stackTrace the stack trace generated by the failure.
     */
    void setStackTrace(String stackTrace);

    /**
     * @return the metrics report.
     */
    ReportLog getReportLog();

    /**
     * @param report the metrics report.
     */
    void setReportLog(ReportLog report);

    /**
     * @return the path of the bug report generated of the failure.
     */
    String getBugReport();

    /**
     * @param path the path of the bug report generated of the failure.
     */
    void setBugReport(String path);

    /**
     * @return the path of the log file generated of the failure.
     */
    String getLog();

    /**
     * @param path the path of the log file generated of the failure.
     */
    void setLog(String path);

    /**
     * @return the path of the screenshot file generated of the failure.
     */
    String getScreenshot();

    /**
     * @param path the path of the screenshot file generated of the failure.
     */
    void setScreenshot(String path);

    /**
     * Report the test as a failure.
     *
     * @param trace the stacktrace of the failure.
     */
    void failed(String trace);

    /**
     * Report that the test has completed.
     *
     * @param report A report generated by the test, or null.
     */
    void passed(ReportLog report);

    /**
     * Report that the test was skipped.
     *
     * This means that the test is not considered appropriate for the
     * current device, and thus is never attempted. The test does not require execution,
     * and nothing more needs to be done.
     */
    void skipped();

    /**
     * Retrieves whether execution for this test result has been determined unnecessary.
     */
    boolean isSkipped();

    /**
     * Resets the result.
     */
    void reset();

    /**
     * Sets whether the test result status has been generated from a previous testing session.
     */
    void setRetry(boolean isRetry);

    /**
     * Retrieves whether the test result status has been generated from a previous testing session.
     */
    boolean isRetry();

    /**
     * Clear the existing result and default to 'failed'
     */
    void removeResult();

    /**
     * This method is to record per-case history for CTS Verifier. If this field is used for large
     * test suites like CTS, it may cause performance issues in APFE. Thus please do not use this
     * field in other test suites.
     *
     * @return The test result histories
     */
    List<TestResultHistory> getTestResultHistories();

    /**
     * Set test result histories of test item. This method is for per-case history in CTS Verifier.
     * If this field is used for large test suites like CTS, it may cause performance issues in
     * APFE. Thus please do not use this field in other test suites.
     *
     * @param resultHistories The test result histories.
     */
    void setTestResultHistories(List<TestResultHistory> resultHistories);

    /**
     * Set test screenshots metadata of test item. This method is for per-case screenshots in CTS
     * Verifier. If this field is used for large test suites like CTS, it may cause performance
     * issues in APFE. Thus please do not use this field in other test suites.
     */
    void setTestScreenshotsMetadata(TestScreenshotsMetadata screenshotsMetadata);

    TestScreenshotsMetadata getTestScreenshotsMetadata();
}
